// © hiimannshu
//@version=5

// This indicator is just a simple indicator which plot any kind of multiple (atmost 10) moving everage (sma/ema/wma/rma/hma/vwma) on chart.
// Enjoy the new update

indicator(title='10 in 1 Different Moving Averages ( SMA/EMA/WMA/RMA/HMA/VWMA )', shorttitle=' 10 in 1 MAs', overlay=true)

bool plot_ma_1 = input.bool(true, 'MA 1',inline='ma1',group= " Simple Moving averages")
string ma_1_type = input.string(defval='EMA', title='',inline='ma1', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],group= " Simple Moving averages")
int ma_1_val = input.int(200, '', minval=1,inline='ma1',group= " Simple Moving averages")
string ma1_res = input.string(title='', defval='Normal MA',inline='ma1',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages")
color ma_1_colour = input.color(color.red, '',inline='ma1',group= " Simple Moving averages")


bool plot_ma_2 = input.bool(false, 'MA 2',inline='ma2',group= " Simple Moving averages")
string ma_2_type = input.string(defval='SMA',inline='ma2', title='', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],group= " Simple Moving averages")
int ma_2_val = input.int(1, '', minval=1,inline='ma2',group= " Simple Moving averages")
string ma2_res = input.string(title='', defval='Normal MA',inline='ma2',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"],group= " Simple Moving averages")
color ma_2_colour = input.color(color.black, '',inline='ma2',group= " Simple Moving averages")


bool plot_ma_3 = input.bool(false, 'MA 3',inline='ma3',group= " Simple Moving averages")
string ma_3_type = input.string(defval='SMA',inline='ma3', title='', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],group= " Simple Moving averages")
int ma_3_val = input.int(1, '', minval=1,inline='ma3',group= " Simple Moving averages")
string ma3_res = input.string(title='',inline='ma3', defval='Normal MA',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"],group= " Simple Moving averages")
color ma_3_colour = input.color(color.black, '',inline='ma3',group= " Simple Moving averages")


bool plot_ma_4 = input.bool(false, 'MA 4',inline='ma4',group= " Simple Moving averages")
string ma_4_type = input.string(defval='SMA', title='',inline='ma4', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],group= " Simple Moving averages")
int ma_4_val = input.int(1, '', minval=1,inline='ma4',group= " Simple Moving averages")
string ma4_res = input.string(title='', inline='ma4',defval='Normal MA',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"],group= " Simple Moving averages")
color ma_4_colour = input.color(color.black, '',inline='ma4',group= " Simple Moving averages")


bool plot_ma_5 = input.bool(false, 'MA 5',inline='ma5',group= " Simple Moving averages")
string ma_5_type = input.string(defval='SMA', title='', inline='ma5',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],group= " Simple Moving averages")
int ma_5_val = input.int(1, '', minval=1,inline='ma5',group= " Simple Moving averages")
string ma5_res = input.string(title='', defval='Normal MA',inline='ma5',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"],group= " Simple Moving averages")
color ma_5_colour = input.color(color.black, '',inline='ma5',group= " Simple Moving averages")


bool plot_ma_6 = input.bool(false, 'MA 6',inline='ma6', group= " Simple Moving averages with smoothing ")
string ma_6_type = input.string(defval='SMA', title='',inline='ma6', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Simple Moving averages with smoothing ")
int ma_6_val = input.int(1, '', minval=1,inline='ma6', group= " Simple Moving averages with smoothing ")
string ma6_res = input.string(title='', inline='ma6',defval='Normal MA',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages with smoothing ")
color ma_6_colour = input.color(color.black, '',inline='ma6', group= " Simple Moving averages with smoothing ")


bool plot_ma_7 = input.bool(false, 'MA 7', inline='ma7',group= " Simple Moving averages with smoothing ")
string ma_7_type = input.string(defval='SMA', title='', inline='ma7',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Simple Moving averages with smoothing ")
int ma_7_val = input.int(1, '', minval=1,inline='ma7', group= " Simple Moving averages with smoothing ")
string ma7_res = input.string(title='', defval='Normal MA',inline='ma7',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages with smoothing ")
color ma_7_colour = input.color(color.black, '',inline='ma7', group= " Simple Moving averages with smoothing ")


bool plot_ma_8 = input.bool(false, 'MA 8',inline='ma8', group= " Simple Moving averages with smoothing ")
string ma_8_type = input.string(defval='SMA', title='',inline='ma8',  options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Simple Moving averages with smoothing ")
int ma_8_val = input.int(1, '', minval=1, inline='ma8', group= " Simple Moving averages with smoothing ")
string ma8_res = input.string(title='', defval='Normal MA',inline='ma8', options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages with smoothing ")
color ma_8_colour = input.color(color.black, '',inline='ma8',  group= " Simple Moving averages with smoothing ")


bool plot_ma_9 = input.bool(false, 'MA 9', inline='ma9', group= " Simple Moving averages with smoothing ")
string ma_9_type = input.string(defval='SMA', title='', inline='ma9', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Simple Moving averages with smoothing ")
int ma_9_val = input.int(1, '', minval=1, inline='ma9', group= " Simple Moving averages with smoothing ")
string ma9_res = input.string(title='', defval='Normal MA', inline='ma9',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages with smoothing ")
color ma_9_colour = input.color(color.black, '', inline='ma9', group= " Simple Moving averages with smoothing ")


bool plot_ma_10 = input.bool(false, 'MA 10', inline='ma10', group= " Simple Moving averages with smoothing ")
string ma_10_type = input.string(defval='SMA', title='',inline='ma10', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Simple Moving averages with smoothing ")
int ma_10_val = input.int(1, '', minval=1,inline='ma10', group= " Simple Moving averages with smoothing ")
string ma10_res = input.string(title='', defval='Normal MA',inline='ma10',options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], group= " Simple Moving averages with smoothing ")
color ma_10_colour = input.color(color.black, '', inline='ma10',group= " Simple Moving averages with smoothing ")


bool plot_ma_6_sm = input.bool(false, 'MA 6', inline='sma6', group= " Use Smoothed Moving Averages ")
int sm_ma_6_val = input.int(1, '', minval=1,inline='sma6',  group= " Use Smoothed Moving Averages ")
string sm_ma_6 =  input.string(defval='SMA',inline='sma6', title='', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'],  group= " Use Smoothed Moving Averages ")
string sh_sm_ma6 = input.string("Show Both MAs",inline='sma6',title = "",options = ["Only Show Smoothed MA ","Show Both MAs"], group= " Use Smoothed Moving Averages ")
color sm_ma_6_colour = input.color(color.black, '', inline='sma6',group= " Use Smoothed Moving Averages ",tooltip ="Activate this if you want a smoother version of MA 6 . To use this you have to activate MA 6 first.")


bool plot_ma_7_sm = input.bool(false, 'MA 7 ',group= " Use Smoothed Moving Averages ", inline='sma7')
int sm_ma_7_val = input.int(1, '', minval=1, inline='sma7', group= " Use Smoothed Moving Averages ")
string sm_ma_7 =  input.string(defval='SMA', inline='sma7', title='', options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Use Smoothed Moving Averages ")
string sh_sm_ma7 = input.string("Show Both MAs",title = "", inline='sma7',options = ["Only Show Smoothed MA ","Show Both MAs"],group= " Use Smoothed Moving Averages ")
color sm_ma_7_colour = input.color(color.black, '', inline='sma7', group= " Use Smoothed Moving Averages ",tooltip ="Activate this if you want a smoother version of MA 7 . To use this you have to activate MA 7 first.")


bool plot_ma_8_sm = input.bool(false, 'MA 8', inline='sma8', group= " Use Smoothed Moving Averages ",tooltip ="Activate this if you want a smoother version of MA 8 . To use this you have to activate MA 8 first.")
int sm_ma_8_val = input.int(1, '', minval=1, inline='sma8', group= " Use Smoothed Moving Averages ")
string sm_ma_8 =  input.string(defval='SMA', title='',  inline='sma8',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Use Smoothed Moving Averages ")
string sh_sm_ma8 = input.string("Show Both MAs",title = "", inline='sma8',options = ["Only Show Smoothed MA ","Show Both MAs"],group= " Use Smoothed Moving Averages ")
color sm_ma_8_colour = input.color(color.black, '', inline='sma8', group= " Use Smoothed Moving Averages ")


bool plot_ma_9_sm = input.bool(false, 'MA 9', inline='sma9', group= " Use Smoothed Moving Averages ")
int sm_ma_9_val = input.int(1, '', minval=1, inline='sma9', group= " Use Smoothed Moving Averages ")
string sm_ma_9 =  input.string(defval='SMA', title='',inline='sma9',  options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Use Smoothed Moving Averages ")
string sh_sm_ma9 = input.string("Show Both MAs",title = "",inline='sma9', options = ["Only Show Smoothed MA ","Show Both MAs"],group= " Use Smoothed Moving Averages ")
color sm_ma_9_colour = input.color(color.black, '',inline='sma9',  group= " Use Smoothed Moving Averages ",tooltip ="Activate this if you want a smoother version of MA 9 . To use this you have to activate MA 9 first.")


bool plot_ma_10_sm = input.bool(false, 'MA 10',inline='sma10',  group= " Use Smoothed Moving Averages ")
int sm_ma_10_val = input.int(1, '', minval=1,inline='sma10',  group= " Use Smoothed Moving Averages ")
string sm_ma_10 =  input.string(defval='SMA', title='',inline='sma10',  options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'], group= " Use Smoothed Moving Averages ")
string sh_sm_ma10 = input.string("Show Both MAs",title = "",inline='sma10', options = ["Only Show Smoothed MA ","Show Both MAs"],group= " Use Smoothed Moving Averages ")
color sm_ma_10_colour = input.color(color.black, '', inline='sma10', group= " Use Smoothed Moving Averages ",tooltip ="Activate this if you want a smoother version of MA 10 . To use this you have to activate MA 10 first.")






ma_function(source, length, type) =>


    if type == 'RMA'
        ta.rma(source, length)
    else if type == 'SMA'
        ta.sma(source, length)
    else if type == 'EMA'
        ta.ema(source, length)
    else if type == 'WMA'
        ta.wma(source, length)
    else if type == 'HMA'
        if(length<2)
            ta.hma(source,2)
        else
            ta.hma(source, length)
    else 
        ta.vwma(source, length)
    
sh(string type) =>
    if type == "Only Show Smoothed MA "
        false
    else
        true

type_nor(type)=>
    if (type == "Open") or (type == "High") or (type == "Low") or (type == "Close") or (type == "Normal MA")
        true
    else
        false 

tf(res)=>

    if (res == "1 Minute")
        '1'
    else if (res == "3 Minutes")
        '3'
    else if (res == "5 Minutes")
        '5'
    else if (res == "15 Minutes")
        '15'
    else if (res == "30 Minutes")
        '30'
    else if (res == "45 Minutes")
        '45'
    else if (res == "1 Hour")
        '60'
    else if (res == "2 Hours")
        '120'
    else if (res == "3 Hours")
        '180'
    else if (res == "4 Hours")
        '240'
    else if (res == "Day")
        'D'
    else if (res =="Week" )
        'W'
    else if (res == "Month")
        'M'
    else
        timeframe.period
 
pr(res)=>
    switch res
        "Open" => open
        "High" => high
        "Low" => low
        "Close" => close
        "hlc3" => hlc3
        "ohlc4" => ohlc4
        "hlcc4" => hlcc4
        =>close

ma_1 = plot_ma_1 ? (type_nor(ma1_res)?ma_function(pr(ma1_res), ma_1_val, ma_1_type):request.security(syminfo.tickerid,tf(ma1_res) , ma_function(close, ma_1_val, ma_1_type))):na
ma_2 = plot_ma_2 ?(type_nor(ma2_res)?ma_function(pr(ma2_res), ma_2_val, ma_2_type):request.security(syminfo.tickerid, tf(ma2_res), ma_function(close, ma_2_val, ma_2_type))):na
ma_3 = plot_ma_3 ?(type_nor(ma3_res)?ma_function(pr(ma3_res), ma_3_val, ma_3_type):request.security(syminfo.tickerid, tf(ma3_res), ma_function(close, ma_3_val, ma_3_type))):na
ma_4 = plot_ma_4 ?(type_nor(ma4_res)?ma_function(pr(ma4_res), ma_4_val, ma_4_type): request.security(syminfo.tickerid, tf(ma4_res), ma_function(close, ma_4_val, ma_4_type))):na
ma_5 = plot_ma_5 ?(type_nor(ma5_res)?ma_function(pr(ma5_res), ma_5_val, ma_5_type):request.security(syminfo.tickerid, tf(ma5_res), ma_function(close, ma_5_val, ma_5_type))):na

ma_6 = plot_ma_6 ?(type_nor(ma6_res)?ma_function(pr(ma6_res), ma_6_val, ma_6_type):request.security(syminfo.tickerid,tf(ma6_res) , ma_function(close, ma_6_val, ma_6_type))):na
ma_7 = plot_ma_7 ?(type_nor(ma7_res)?ma_function(pr(ma7_res), ma_7_val, ma_7_type):request.security(syminfo.tickerid,tf(ma7_res) , ma_function(close, ma_7_val, ma_7_type))):na
ma_8 = plot_ma_8 ?(type_nor(ma8_res)?ma_function(pr(ma8_res), ma_8_val, ma_8_type):request.security(syminfo.tickerid,tf(ma8_res) , ma_function(close, ma_8_val, ma_8_type))):na
ma_9 = plot_ma_9 ?(type_nor(ma9_res)?ma_function(pr(ma9_res), ma_9_val, ma_9_type):request.security(syminfo.tickerid,tf(ma9_res) , ma_function(close, ma_9_val, ma_9_type))):na
ma_10 = plot_ma_10 ?(type_nor(ma10_res)?ma_function(pr(ma10_res), ma_10_val, ma_10_type):request.security(syminfo.tickerid,tf(ma10_res) , ma_function(close, ma_10_val, ma_10_type))):na

sm_ma6 = plot_ma_6_sm ?ma_function(ma_6,sm_ma_6_val,sm_ma_6):na
sm_ma7 =  plot_ma_7_sm ?ma_function(ma_7,sm_ma_7_val,sm_ma_7):na
sm_ma8 =  plot_ma_8_sm ?ma_function(ma_8,sm_ma_8_val,sm_ma_8):na
sm_ma9 = plot_ma_9_sm ?ma_function(ma_9,sm_ma_9_val,sm_ma_9):na
sm_ma10 = plot_ma_10_sm ?ma_function(ma_10,sm_ma_10_val,sm_ma_10):na




plot(plot_ma_1 ? ma_1 : na, 'MA 1', ma_1_colour,linewidth = 1 )
plot(plot_ma_2 ? ma_2 : na, 'MA 2', ma_2_colour,linewidth = 1)
plot(plot_ma_3 ? ma_3 : na, 'MA 3', ma_3_colour,linewidth = 1)
plot(plot_ma_4 ? ma_4 : na, 'MA 4', ma_4_colour,linewidth = 1)
plot(plot_ma_5 ? ma_5 : na, 'MA 5', ma_5_colour,linewidth = 1)

plot(plot_ma_6 and sh(sh_sm_ma6)? ma_6 : na, 'MA 6', ma_6_colour,linewidth = 1)
plot(plot_ma_6_sm ? sm_ma6 : na, 'MA 6 Smoothed', sm_ma_6_colour,linewidth = 1)

plot(plot_ma_7 and sh(sh_sm_ma7) ? ma_7 : na, 'MA 7', ma_7_colour,linewidth = 1)
plot(plot_ma_7_sm ? sm_ma7 : na, 'MA 7 Smoothed', sm_ma_7_colour,linewidth = 1)

plot(plot_ma_8 and sh(sh_sm_ma8)? ma_8 : na, 'MA 8', ma_8_colour,linewidth = 1)
plot(plot_ma_8_sm ? sm_ma8 : na, 'MA 8 Smoothed', sm_ma_8_colour,linewidth = 1)

plot(plot_ma_9 and sh(sh_sm_ma9)? ma_9 : na, 'MA 9', ma_9_colour,linewidth = 1)
plot(plot_ma_9_sm ? sm_ma9 : na, 'MA 9 Smoothed', sm_ma_9_colour,linewidth = 1)

plot(plot_ma_10 and sh(sh_sm_ma10)? ma_10 : na, 'MA 10', ma_10_colour,linewidth = 1)
plot(plot_ma_10_sm ? sm_ma10 : na, 'MA 10 Smoothed', sm_ma_10_colour,linewidth = 1)
